#include "ZeroColor.h"
#include "../utils/Logger.h"

ZeroColor::ZeroColor(int colorIndex) :
        colorIndex(colorIndex)
{
}

ZeroColor::~ZeroColor() {
}

IplImage* ZeroColor::apply(const IplImage* in) {
    Log << "Applying zero color effect: " <<
            colorIndex << endl;

    IplImage *out = cvCreateImage(cvSize(in->width, in->height), in->depth, in->nChannels);
    cvCopy(in, out);

    for (int y = 0; y < out->height; y++) {
        uchar *ptr = (uchar*) (out->imageData + y * out->widthStep);
        for (int x = 0; x < out->width; x++) {
            ptr[out->nChannels * x + colorIndex] = 0;
        }
    }

    return out;
}
